package com.map.dao;

import com.map.util.User;
import org.nutz.dao.Cnd;
import org.nutz.dao.impl.NutDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

/**
 * Created by JIAO on 2016/4/12.
 */
@Repository
public class UserDAO {

    private NutDao nutDao;

    @Autowired
    public void setNutDao(NutDao nutDao) {
        this.nutDao = nutDao;
    }

    public Boolean check(String username, String password) {
        return nutDao.query(User.class, Cnd.where("user_name", "=", username).and("password", "=", password)).size() > 0;
    }
    public boolean addUser(User user){
        nutDao.insert(user);
        return true;
    }
    public boolean existUser(String username){
        return nutDao.query(User.class,Cnd.where("user_name","=",username)).size()>0;
    }
}
